Update PHPDoc for patch commands#107
Conversation
- Remove extra spaces in `cache patch` PHPDoc annotation - Specify default value for `expiration` argument in `transient patch` PHPDoc annotation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
src/Transient_Command.php
Outdated
| public function patch( $args, $assoc_args ) { | ||
| list( $action, $key ) = $args; | ||
| $expiration = (int) Utils\get_flag_value( $assoc_args, 'expiration', 0 ); | ||
| $expiration = (int) Utils\get_flag_value( $assoc_args, 'expiration' ); |
There was a problem hiding this comment.
I assume you remove the 0 here for consistency with the other commands, but I think this is the only one that is actually correct. For all of the expiration flags, we should:
- be explicit with the default value (as it will otherwise default to
null) - cast to the expected type
(int)to ensure we don't see unexpected changes later in the code
There was a problem hiding this comment.
1/
Yes it was for consistency, I removed the default value here and set it in the PHPDoc like what was done in the cache command.
During my testing, I saw that the default value from the PHPDoc was automatically used without having to set it in get_flag_value. I thought it was cleaner, and I apply the change here.
I can add the 0 back here and in the cache command if you think it's more explicit ?
2/
I've done that in 4bf6850
cache patchPHPDoc annotationexpirationargument intransient patchPHPDoc annotation